package com.hhj.sharding.sphere.demo.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hhj.sharding.sphere.demo.model.TableParamVO;
import com.hhj.sharding.sphere.demo.model.UserParamVO;
import com.hhj.sharding.sphere.demo.model.entity.SingleTable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hhj.sharding.sphere.demo.model.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author HHJ
 * @since 2024-05-22
 */
public interface SingleTableMapper extends BaseMapper<SingleTable> {

    @Select("<script>" +

            " SELECT RE.* FROM tb_single_table RE " +
            " WHERE RE.id > 0 " +

            " <if test=\"req.id != null \"> " +
            " AND RE.id = #{req.id}" +
            " </if> " +

            " <if test=\"req.code != null \"> " +
            " AND RE.code = #{req.code}" +
            " </if> " +

            " <if test=\"req.title != null \"> " +
            " AND RE.title = #{req.title}" +
            " </if> " +

            " ORDER BY RE.id DESC" +

            "</script>")
    List<SingleTable> findList(@Param("page") Page page, @Param("req") TableParamVO req);

}
